/**
 * @program: LeetCode
 * @description: LeetCode : 206. 反转链表
 * @author: WXY
 * @create: 2023-01-02 15:04
 * @Version 1.0
 **/
public class num206_reverseList {
    public ListNode reverseList(ListNode head) {
        ListNode pre = null;
        ListNode next = null;
        while (head != null) {
            next = head.next;
            head.next = pre;
            pre = head;
            head = next;
        }
        return pre;
    }

    class ListNode {
        int val;
        ListNode next;

        ListNode(int x) {
            val = x;
            next = null;
        }
    }


}
